home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / CMApplication.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  10.9 KB  |  387 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        CMApplication.h
  3.  
  4.      Contains:    Color Matching Application Interfaces.
  5.  
  6.      Version:    Technology:    Color Sync 1.0.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __CMAPPLICATION__
  21. #define __CMAPPLICATION__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __QUICKDRAW__
  30. #include <Quickdraw.h>
  31. #endif
  32. /*    #include <MixedMode.h>                                        */
  33. /*    #include <QuickdrawText.h>                                    */
  34.  
  35. #ifndef __WINDOWS__
  36. #include <Windows.h>
  37. #endif
  38. /*    #include <Memory.h>                                            */
  39. /*    #include <Events.h>                                            */
  40. /*        #include <OSUtils.h>                                    */
  41. /*    #include <Controls.h>                                        */
  42. /*        #include <Menus.h>                                        */
  43.  
  44. #ifndef __PRINTING__
  45. #include <Printing.h>
  46. #endif
  47. /*    #include <Errors.h>                                            */
  48. /*    #include <Dialogs.h>                                        */
  49. /*        #include <TextEdit.h>                                    */
  50.  
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54.  
  55. #if PRAGMA_ALIGN_SUPPORTED
  56. #pragma options align=mac68k
  57. #endif
  58.  
  59. #if PRAGMA_IMPORT_SUPPORTED
  60. #pragma import on
  61. #endif
  62.  
  63.  
  64. enum {
  65.     CMTrap                        = 0xABEE
  66. };
  67.  
  68. /* PicComments */
  69. enum {
  70.     CMBeginProfile                = 220,
  71.     CMEndProfile                = 221,
  72.     CMEnableMatching            = 222,
  73.     CMDisableMatching            = 223
  74. };
  75.  
  76. /* Defines for fieldMask in profile search record */
  77. enum {
  78.     kMatchCMMType                = 0x00000001,
  79.     kMatchApplProfileVersion    = 0x00000002,
  80.     kMatchDataType                = 0x00000004,
  81.     kMatchDeviceType            = 0x00000008,
  82.     kMatchDeviceManufacturer    = 0x00000010,
  83.     kMatchDeviceModel            = 0x00000020,
  84.     kMatchDeviceAttributes        = 0x00000040,
  85.     kMatchFlags                    = 0x00000080,
  86.     kMatchOptions                = 0x00000100,
  87.     kMatchWhite                    = 0x00000200,
  88.     kMatchBlack                    = 0x00000400
  89. };
  90.  
  91. /* Profile Header version */
  92. enum {
  93.     kCMApplProfileVersion        = 0x0100
  94. };
  95.  
  96. /* Data types */
  97. enum {
  98.     rgbData                        = 'RGB ',
  99.     cmykData                    = 'CMYK',
  100.     grayData                    = 'GRAY',
  101.     xyzData                        = 'XYZ '
  102. };
  103.  
  104. /* Device types */
  105. enum {
  106.     monitorDevice                = 'mntr',
  107.     scannerDevice                = 'scnr',
  108.     printerDevice                = 'prtr',
  109.     qdSystemDevice                = 'sys ',
  110.     qdGDevice                    = 'gdev'
  111. };
  112.  
  113. /* Profile flags */
  114. enum {
  115.     CMNativeMatchingPreferred    = 0x00000001,                    /* Default to native not preferred */
  116.     CMTurnOffCache                = 0x00000002                    /* Default to turn on CMM cache */
  117. };
  118.  
  119. typedef long CMMatchFlag;
  120.  
  121. /* Profile options */
  122.  
  123. enum {
  124.     CMPerceptualMatch            = 0x0000,                        /* Default. For photographic images */
  125.     CMColorimetricMatch            = 0x0001,                        /* Exact matching when possible */
  126.     CMSaturationMatch            = 0x0002                        /* For solid colors */
  127. };
  128.  
  129. typedef long CMMatchOption;
  130.  
  131. typedef long CMMatchRef;
  132.  
  133. typedef long CWorld;
  134.  
  135. /* ColorSync result codes */
  136.  
  137. enum {
  138.     CMNoError                    = 0,
  139.     CMProfileError                = -170,
  140.     CMMethodError                = -171,
  141.     CMMemFullError                = -172,
  142.     CMUnimplementedError        = -173,
  143.     CMParamError                = -174,
  144.     CMMethodNotFound            = -175,                            /* CMM not present */
  145.     CMProfileNotFound            = -176,                            /* Responder error */
  146.     CMProfilesIdentical            = -177,                            /* Profiles the same */
  147.     CMCantConcatenateError        = -178,                            /* Profile can't be concatenated */
  148.     CMCantXYZ                    = -179,                            /* CMM cant handle XYZ space */
  149.     CMCantDeleteProfile            = -180,                            /* Responder error */
  150.     CMUnsupportedDataType        = -181,                            /* Responder error */
  151.     CMNoCurrentProfile            = -182                            /* Responder error */
  152. };
  153.  
  154. typedef long CMError;
  155.  
  156. /*
  157. ** Types
  158. */
  159. struct XYZColor {
  160.     unsigned short                    X;                            /* 1.15 bit unsigned fixed numbers */
  161.     unsigned short                    Y;
  162.     unsigned short                    Z;
  163. };
  164. typedef struct XYZColor XYZColor;
  165.  
  166. struct CMYKColor {
  167.     unsigned short                    cyan;
  168.     unsigned short                    magenta;
  169.     unsigned short                    yellow;
  170.     unsigned short                    black;
  171. };
  172. typedef struct CMYKColor CMYKColor;
  173.  
  174. union CMColor {
  175.     RGBColor                        rgb;
  176.     XYZColor                        xyz;
  177.     CMYKColor                        cmyk;
  178. };
  179. typedef union CMColor CMColor, *CMColorList;
  180.  
  181. typedef long *CMGamutResult;
  182.  
  183. struct CMHeader {
  184.     unsigned long                    size;                        /* This is the total size of the Profile including custom data */
  185.     OSType                            CMMType;                    /* Corresponding CMM */
  186.     unsigned long                    applProfileVersion;            /* Version of CMProfile format */
  187.     OSType                            dataType;                    /* rgbData, etc. */
  188.     OSType                            deviceType;                    /* monitorDevice, etc. */
  189.     OSType                            deviceManufacturer;            /* Registered with DTS */
  190.     unsigned long                    deviceModel;                /* Specific to Manufacturer */
  191.     unsigned long                    deviceAttributes[2];        /* Attributes like paper, ink, etc. */
  192.     unsigned long                    profileNameOffset;            /* Offset to profile name from top of data */
  193.     unsigned long                    customDataOffset;            /* Offset to custom data from top of data */
  194.     CMMatchFlag                        flags;
  195.     CMMatchOption                    options;
  196.     XYZColor                        white;
  197.     XYZColor                        black;
  198. };
  199. typedef struct CMHeader CMHeader;
  200.  
  201. struct CMProfileSearchRecord {
  202.     CMHeader                        header;
  203.     unsigned long                    fieldMask;
  204.     unsigned long                    reserved[2];
  205. };
  206. typedef struct CMProfileSearchRecord CMProfileSearchRecord, **CMProfileSearchRecordHandle;
  207.  
  208. struct CMProfileChromaticities {
  209.     XYZColor                        red;
  210.     XYZColor                        green;
  211.     XYZColor                        blue;
  212.     XYZColor                        cyan;
  213.     XYZColor                        magenta;
  214.     XYZColor                        yellow;
  215. };
  216. typedef struct CMProfileChromaticities CMProfileChromaticities;
  217.  
  218. typedef unsigned short CMResponseData;
  219.  
  220. struct IString {
  221.     ScriptCode                        theScript;
  222.     Str63                            theString;
  223. };
  224. typedef struct IString IString, *IStringPtr, **IStringHandle;
  225.  
  226.  
  227. enum {
  228.     grayResponse                = 0,
  229.     redResponse                    = 1,
  230.     greenResponse                = 2,
  231.     blueResponse                = 3,
  232.     cyanResponse                = 4,
  233.     magentaResponse                = 5,
  234.     yellowResponse                = 6,
  235.     ucrResponse                    = 7,
  236.     bgResponse                    = 8,
  237.     onePlusLastResponse            = 9
  238. };
  239.  
  240. typedef long responseColor;
  241.  
  242. struct CMProfileResponse {
  243.     unsigned short                    counts[onePlusLastResponse];
  244.     CMResponseData                    data[1];                    /* Variable size */
  245. };
  246. typedef struct CMProfileResponse CMProfileResponse;
  247.  
  248. struct CMProfile {
  249.     CMHeader                        header;
  250.     CMProfileChromaticities            profile;
  251.     CMProfileResponse                response;                    /* Variable size */
  252.     IString                            profileName;                /* Variable size */
  253.     SInt8                            customData[1];                /* Optional variable length custom CMM data */
  254. };
  255. typedef struct CMProfile CMProfile, *CMProfilePtr, **CMProfileHandle;
  256.  
  257. typedef pascal Boolean (*PixMapCallBackProcPtr)(long progress, long refCon);
  258.  
  259. #if GENERATINGCFM
  260. typedef UniversalProcPtr PixMapCallBackUPP;
  261. #else
  262. typedef PixMapCallBackProcPtr PixMapCallBackUPP;
  263. #endif
  264.  
  265. enum {
  266.     uppPixMapCallBackProcInfo = kPascalStackBased
  267.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  268.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  269.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  270. };
  271.  
  272. #if GENERATINGCFM
  273. #define NewPixMapCallBackProc(userRoutine)        \
  274.         (PixMapCallBackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppPixMapCallBackProcInfo, GetCurrentArchitecture())
  275. #else
  276. #define NewPixMapCallBackProc(userRoutine)        \
  277.         ((PixMapCallBackUPP) (userRoutine))
  278. #endif
  279.  
  280. #if GENERATINGCFM
  281. #define CallPixMapCallBackProc(userRoutine, progress, refCon)        \
  282.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppPixMapCallBackProcInfo, (progress), (refCon))
  283. #else
  284. #define CallPixMapCallBackProc(userRoutine, progress, refCon)        \
  285.         (*(userRoutine))((progress), (refCon))
  286. #endif
  287.  
  288. /*
  289. ** Printing Stuff that will be moved later
  290. */
  291.  
  292. enum {
  293.     enableColorMatchingOp        = 12,
  294.     registerProfileOp            = 13
  295. };
  296.  
  297. /* PrGeneral parameter blocks */
  298. struct TEnableColorMatchingBlk {
  299.     short                            iOpCode;
  300.     short                            iError;
  301.     long                            lReserved;
  302.     THPrint                            hPrint;
  303.     Boolean                            fEnableIt;
  304.     SInt8                            filler;
  305. };
  306. typedef struct TEnableColorMatchingBlk TEnableColorMatchingBlk;
  307.  
  308. struct TRegisterProfileBlk {
  309.     short                            iOpCode;
  310.     short                            iError;
  311.     long                            lReserved;
  312.     THPrint                            hPrint;
  313.     Boolean                            fRegisterIt;
  314.     SInt8                            filler;
  315. };
  316. typedef struct TRegisterProfileBlk TRegisterProfileBlk;
  317.  
  318. /*
  319. ** High Level Calls
  320. */
  321. extern pascal CMError BeginMatching(CMProfileHandle src, CMProfileHandle dst, CMMatchRef *myRef)
  322.  FOURWORDINLINE(0x203c, 0x000C, 10, 0xABEE);
  323. extern pascal void EndMatching(CMMatchRef myRef)
  324.  FOURWORDINLINE(0x203c, 0x0004, 11, 0xABEE);
  325. extern pascal CMError GetProfile(long deviceType, long refNum, CMProfileHandle aProfile, CMProfileHandle *returnedProfile)
  326.  FOURWORDINLINE(0x203c, 0x0010, 5, 0xABEE);
  327. extern pascal CMError SetProfile(long deviceType, long refNum, CMProfileHandle newProfile)
  328.  FOURWORDINLINE(0x203c, 0x000c, 6, 0xABEE);
  329. extern pascal CMError SetProfileDescription(long deviceType, long refNum, long deviceData, CMProfileHandle hProfile)
  330.  FOURWORDINLINE(0x203c, 0x0010, 16, 0xABEE);
  331. extern pascal CMError GetColorSyncFolderSpec(short vRefNum, Boolean createFolder, short *foundVRefNum, long *foundDirID)
  332.  FOURWORDINLINE(0x203c, 0x000c, 17, 0xABEE);
  333. extern pascal CMError GetIndexedProfile(long deviceType, long refNum, CMProfileSearchRecordHandle search, CMProfileHandle *returnProfile, long *index)
  334.  FOURWORDINLINE(0x203c, 0x0014, 18, 0xABEE);
  335. extern pascal CMError DeleteDeviceProfile(long deviceType, long refNum, CMProfileHandle deleteMe)
  336.  FOURWORDINLINE(0x203c, 0x000C, 19, 0xABEE);
  337. /*
  338. ** Data interchange routines
  339. */
  340. extern pascal CMError UseProfile(CMProfileHandle profile)
  341.  FOURWORDINLINE(0x203c, 0x0004, 8, 0xABEE);
  342. extern pascal void DrawMatchedPicture(PicHandle myPicture, CMProfileHandle dst, Rect *myRect)
  343.  FOURWORDINLINE(0x203c, 0x000C, 9, 0xABEE);
  344. extern pascal void EnableMatching(Boolean enableIt)
  345.  FOURWORDINLINE(0x203c, 0x0002, 13, 0xABEE);
  346. /*
  347. ** Profile concatenation
  348. */
  349. extern pascal CMError ConcatenateProfiles(CMProfileHandle thru, CMProfileHandle dst, CMProfileHandle *newDst)
  350.  FOURWORDINLINE(0x203c, 0x000C, 12, 0xABEE);
  351. /*
  352. ** Profile manipulation routines
  353. */
  354. extern pascal void GetProfileName(CMProfileHandle myProfile, IString *IStringResult)
  355.  FOURWORDINLINE(0x203c, 0x0008, 14, 0xABEE);
  356. extern pascal long GetProfileAdditionalDataOffset(CMProfileHandle myProfile)
  357.  FOURWORDINLINE(0x203c, 0x0004, 15, 0xABEE);
  358. /*
  359. ** Low level color calculation routines
  360. */
  361. extern pascal CMError CWNewColorWorld(CWorld *myCWorld, CMProfileHandle src, CMProfileHandle dst)
  362.  FOURWORDINLINE(0x203c, 0x000C, 0, 0xABEE);
  363. extern pascal void CWDisposeColorWorld(CWorld myCWorld)
  364.  FOURWORDINLINE(0x203c, 0x0004, 1, 0xABEE);
  365. extern pascal CMError CWMatchColors(CWorld myCWorld, CMColorList myColors, long count)
  366.  FOURWORDINLINE(0x203c, 0x000c, 2, 0xABEE);
  367. extern pascal CMError CWCheckColors(CWorld myCWorld, CMColorList myColors, long count, CMGamutResult result)
  368.  FOURWORDINLINE(0x203c, 0x0010, 3, 0xABEE);
  369. extern pascal CMError CWMatchPixMap(CWorld myCWorld, PixMap *myPixMap, PixMapCallBackUPP progressProc, long refCon)
  370.  FOURWORDINLINE(0x203c, 0x0010, 4, 0xABEE);
  371. extern pascal CMError CWCheckPixMap(CWorld myCWorld, PixMap *myPixMap, PixMapCallBackUPP progressProc, long refCon, BitMap *resultBitMap)
  372.  FOURWORDINLINE(0x203c, 0x0014, 7, 0xABEE);
  373.  
  374. #if PRAGMA_IMPORT_SUPPORTED
  375. #pragma import off
  376. #endif
  377.  
  378. #if PRAGMA_ALIGN_SUPPORTED
  379. #pragma options align=reset
  380. #endif
  381.  
  382. #ifdef __cplusplus
  383. }
  384. #endif
  385.  
  386. #endif /* __CMAPPLICATION__ */
  387.